package org.bizming.web.util;

import java.util.List;

import org.bizming.base.BaseModel;
import org.bizming.medicine.model.help.ActionType;

public class Helper {

	/**
	 * 验证对象是否正确
	 * 
	 * @param t
	 * @param type
	 * @return
	 */
	public static boolean validate(BaseModel t, ActionType type) {
		if (t != null && t.isValidate(type))
			return true;
		return false;
	}

	public static boolean isEmpty(String str) {
		if (str == null || str.equals(""))
			return true;
		return false;
	}

	public static boolean isEmptyTrim(String str) {
		if (str == null || str.trim().equals(""))
			return true;
		return false;
	}

	public static <E> boolean isEmpty(List<E> list) {
		if (list == null || list.size() == 0)
			return true;
		return false;
	}

	public static String nullToString(String str) {
		if (str == null) {
			str = "";
		}
		return str;
	}
}
